package com.wanjia.order.server.controller;


import com.wanjia.order.server.entity.UserOrder;
import com.wanjia.order.server.mapper.OrderMapper;

import com.wanjia.order.server.service.OrderService;
import com.wanjia.project.commons.bo.order.OrderAddBO;
import com.wanjia.project.commons.bo.order.OrderListBO;
import com.wanjia.project.commons.dto.ResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;


@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @PostMapping("/orderlist")
    public ResultDTO orderList(@RequestBody OrderListBO orderListBO){

        List<UserOrder> userOrders = orderService.orderList(orderListBO);
        return new ResultDTO(200,"成功",userOrders);
    }
    @PostMapping("/add")
    public ResultDTO add(@RequestBody OrderAddBO orderAddBO){
        orderService.addOrder(orderAddBO);
        return new ResultDTO(200,"新增成功",null);
    }

}
